import { getRequest, optionRequestToOceanImg } from '../api.js';

export default {
    async getSerialdata(dates, depth, target, time, type) {
        let url = `/api/seadata/serialdata?dates=${dates}&depth=${Math.abs(depth)}&target=${target}&time=${time}&type=${type}`;
        return new Promise((resolve, reject) => {
            getRequest(url).then(res => {
                resolve(res);
            });
        });
    },

    async getOceanDepth(lat, lng) {
        let url = `/v1/gebco2022?locations=${lat},${lng}`;
        return new Promise((resolve, reject) => {
            getRequest(url).then(res => {
                resolve(res);
            });
        });
    },

    async optionRequestToOceanImg(url, name) {
        return new Promise((resolve, reject) => {
            optionRequestToOceanImg(url).then((res) => {
                let result = { isOk: res.status == 200, name };
                resolve(result);
            });
        });
    }
}